package com.shigen.file.service.impl;

import com.shigen.file.entity.FirstMenu;
import com.shigen.file.mapper.FirstMenuMapper;
import com.shigen.file.service.IFirstMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shigen.file.service.ISecondMenuService;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 一级菜单 服务实现类
 * </p>
 *
 * @author shigen.fu
 * @since 2022-06-04
 */
@Service
public class FirstMenuServiceImpl extends ServiceImpl<FirstMenuMapper, FirstMenu> implements IFirstMenuService {

  @Resource
  private ISecondMenuService secondMenuService;

  @Override
  public List<FirstMenu> getAllMenus() {
    List<FirstMenu> firstMenus = getBaseMapper().selectList(null);
    firstMenus.forEach(firstMenu -> firstMenu.setSecondMenus(secondMenuService.getMenusByParentId(firstMenu.getId())));
    return firstMenus;
  }
}
